// +----------------------------------------------------------------------
// | JavaWeb_Vue_Pro前后端分离旗舰版框架 [ JavaWeb ]
// +----------------------------------------------------------------------
// | 版权所有 2019~2020 南京JavaWeb研发中心
// +----------------------------------------------------------------------
// | 官方网站: http://www.javaweb.vip/
// +----------------------------------------------------------------------
// | 作者: 鲲鹏 <1175401194@qq.com>
// +----------------------------------------------------------------------

package com.javaweb.system.controller;

import com.javaweb.common.enums.LogType;
import com.javaweb.system.common.BaseController;
import com.javaweb.system.entity.AuthGroup;
import com.javaweb.system.query.AuthGroupQuery;
import com.javaweb.system.service.IAuthGroupService;
import com.javaweb.common.annotation.Log;
import com.javaweb.common.utils.JsonResult;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 分组表 前端控制器
 * </p>
 *
 * @author 鲲鹏
 * @since 2021-06-04
 */
@RestController
@RequestMapping("/authgroup")
public class AuthGroupController extends BaseController {

    @Autowired
    private IAuthGroupService authGroupService;

    /**
     * 获取数据列表
     *
     * @param query 查询条件
     * @return
     */
    @RequiresPermissions("sys:authgroup:index")
    @GetMapping("/index")
    public JsonResult index(AuthGroupQuery query) {
        return authGroupService.getList(query);
    }

    /**
     * 添加记录
     *
     * @param entity 实体对象
     * @return
     */
    @Log(title = "分组表", logType = LogType.INSERT)
    @RequiresPermissions("sys:authgroup:add")
    @PostMapping("/add")
    public JsonResult add(@RequestBody AuthGroup entity) {
        return authGroupService.edit(entity);
    }

    /**
     * 获取详情
     *
     * @param authgroupId 记录ID
     * @return
     */
    @GetMapping("/info/{authgroupId}")
    public JsonResult info(@PathVariable("authgroupId") Integer authgroupId) {
        return authGroupService.info(authgroupId);
    }

    /**
     * 更新记录
     *
     * @param entity 实体对象
     * @return
     */
    @Log(title = "分组表", logType = LogType.UPDATE)
    @RequiresPermissions("sys:authgroup:edit")
    @PutMapping("/edit")
    public JsonResult edit(@RequestBody AuthGroup entity) {
        return authGroupService.edit(entity);
    }

    /**
     * 删除记录
     *
     * @param authgroupIds 记录ID
     * @return
     */
    @Log(title = "分组表", logType = LogType.DELETE)
    @RequiresPermissions("sys:authgroup:drop")
    @DeleteMapping("/delete/{authgroupIds}")
    public JsonResult delete(@PathVariable("authgroupIds") Integer[] authgroupIds) {
        return authGroupService.deleteByIds(authgroupIds);
    }

}